#include "ConcurrentAlloc.h"

void Alloc1()
{
    for (int i = 0; i < 5; i++)
    {
        void* ptr = ConcurrentAlloc(6);
    }
}
void Alloc2()
{
    for (int i = 0; i < 5; i++)
    {
        void* ptr = ConcurrentAlloc(7);
    }
}

void TestConCurrentAlloc()
{
    void *p1 = ConcurrentAlloc(10);
    void *p2 = ConcurrentAlloc(6);
    void *p3 = ConcurrentAlloc(7);
    void *p4 = ConcurrentAlloc(1);

    cout << p1 << endl;
    cout << p2 << endl;
    cout << p3 << endl;
    cout << p4 << endl;

}
void TLSTest()
{
    std::thread t1(Alloc1);
    std::thread t2(Alloc2);

    t1.join();
    
    t2.join();
}

int main()
{
    srand(time(nullptr));
    TLSTest();
    cout << "_________________" << endl;
    TestConCurrentAlloc();
    return 0;
}